package org.destiny.hello.world.controller;

import java.util.ArrayList;
import java.util.List;

import org.destiny.hello.world.entity.Student;
import org.destiny.hello.world.respository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private StudentRepository studentRepository;

    @RequestMapping("/queryStudentAll")
    public List<Student> queryStudentAll() {
        return studentRepository.findAll();
    }

    @RequestMapping("/test1")
    public List<Student> test1() {
        List<Student> students = new ArrayList<>();
        return students;
    }

    /**
     * 测试fastjson，如果为null的话，返回空字符串
     * 
     * @return
     */
    @RequestMapping("/test2")
    public List<Student> test2() {
        List<Student> students = new ArrayList<>();
        Student student = new Student();
        student.setId(000l);
        student.setUserName("张三");
        students.add(student);
        return students;
    }
}
